<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      /**
       * @param {string} s
       * @param {string} t
       * @return {boolean}
       */
      var isAnagram = function (s, t) {
        if (s.length !== t.length) return false;
        s = s.split("").sort();
        t = t.split("").sort();
        for (var i = 0; i < s.length; i++) {
          if (s[i] !== t[i]) return false;
        }
        return true;
      };

      var s = "anagram";
      var t = "nagaram";
      console.log(isAnagram(s, t));
    </script>
  </body>
</html>
